import request from '@/utils/request'

// 列表
export function getAddonGroupList(page, size, group_name) {
  return request({
    url: '/addonGroup/getList',
    method: 'get',
    params: { page, size, group_name }
  })
}

// 创建表单
export function getAddonGroupCreate() {
  return request({
    url: '/addonGroup/getCreateForm',
    method: 'post'
  })
}

// 编辑表单
export function getAddonGroupEdit(id) {
  return request({
    url: '/addonGroup/getEditForm',
    data: { id },
    method: 'post'
  })
}

// 删除
export function delAddonGroup(id) {
  return request({
    url: '/addonGroup/delete',
    data: { id },
    method: 'post'
  })
}

// 添加应用到默认组
export function addAddonToDefaultGroup(addonName) {
  return request({
    url: '/addonGroup/addDefaultAddon',
    method: 'post',
    data: { addon_name: addonName }
  })
}

/** *******************************************用户-应用-应用组******************************************************/

// export function getUserAddonAuthForm(uid) {
//   return request({
//     // url: '/addonGroup/user/getUserAddonAuthForm',
//     url: 'UserAddonAuth/getUserAddonAuthForm',
//     method: 'post',
//     data: { uid }
//   })
// }

/** ********************************************用户-应用-平台*******************************************************/
/**
 * 获取用户有权限的应用
 * @param page
 * @param size
 * @param plaid
 * @param uid
 * @param exclude  0=全部，1=未添加的应用，2=已添加的应用
 * @returns {AxiosPromise}
 */
export function getUserAddonList(page, size = 10, plaid, uid = 0, exclude = 0) {
  return request({
    url: '/userPlatformAddonAuth/getUserAddonList',
    method: 'post',
    data: { page, size, plaid, uid, exclude }
  })
}

/**
 * 获取用户有权限的应用小程序
 * @param page
 * @param size
 * @param plaid
 * @param uid
 * @param exclude  0=全部，1=未添加的应用，2=已添加的应用
 * @returns {AxiosPromise}
 */
export function getUserAddonAppList(page, size = 10, plaid, uid = 0, exclude = 0) {
  return request({
    url: '/userPlatformAddonAuth/getUserAddonAppList',
    method: 'post',
    data: { page, size, plaid, uid, exclude }
  })
}
